// pages/study/study.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    study: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getStudyData()
  },
  async getStudyData() {
    const res = await wx.$request({
      url: 'study/progress'
    })
    //  console.log(res)
    if (res.status === 0) {
      res.message.forEach(item => {
        if (item.study_progress <= 30) {
          item.color = '#ff0000'
        } else if (item.study_progress > 30 && item.study_progress <= 80) {
          item.color = '#ff951f'
        } else if (item.study_progress > 80) {
          item.color = '#b4d66e'
        }
      });
      this.setData({
        study: res.message
      })
    }
  }
})